from django.db import models

class Category(models.Model):
    name= models.CharField(max_length=100)
    def __str__(self):
        return "<category:(id:%s;name:%s)>" % (self.id,self.name)
class Tag(models.Model):
    name = models.CharField(max_length=100)
    articles = models.ManyToManyField('Article',related_name='tags')
    def __str__(self):
        return "<tag:(id:%s;name:%s)>" % (self.id,self.name)

# Create your models here.
class Article(models.Model):
    title = models.CharField(max_length=100)
    content = models.TextField()
    category = models.ForeignKey("Category",on_delete=models.CASCADE,null=True,related_name="articles",related_query_name='article')
    author = models.ForeignKey("frontuser.FrontUser",on_delete=models.CASCADE,null=True)

    def __str__(self):
        return "<article:(id:%s;title:%s)>" % (self.id,self.title)

